package com.ssfGame.puremvc.view.application
{
	
	import com.game.utils.GlobalFun;
	import com.ssfGame.puremvc.StaticConst;
	import com.ssfGame.puremvc.view.vc.SceneLayerVC;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	/**
	 * 
	 * @author chery
	 */
	public class SceneLayerMediator extends Mediator
	{
		/**
		 * 
		 * @default 
		 */
		public static const NAME:String="SceneLayerMediator";
		public static const DEL_ALL:String="del_all"//删除场景所有显示对象
			
		/**
		 * 
		 * @param mediatorName
		 * @param viewComponent
		 */
		public function SceneLayerMediator(mediatorName:String=null, viewComponent:Object=null)
		{
			super(mediatorName, viewComponent);
		}
		override public function listNotificationInterests():Array{
			return[
				StaticConst.N_M_SCENE_LAYER_ADD,
				StaticConst.N_M_SCENE_LAYER_DEL
			]
		}
		override public function handleNotification(notification:INotification):void{
			
			var disObj:DisplayObject=notification.getBody() as DisplayObject;
			var _type:String=notification.getType();
			
			switch(notification.getName()){
				case StaticConst.N_M_SCENE_LAYER_ADD:
					
					if(disObj!=null&&!sceneLayerVC.contains(disObj)){
						sceneLayerVC.addChild(disObj)
					}
					break
				case StaticConst.N_M_SCENE_LAYER_DEL:
					if(_type==DEL_ALL){
						GlobalFun.removeAllDisObj(sceneLayerVC);
					}else	if(disObj!=null&&sceneLayerVC.contains(disObj)){
						sceneLayerVC.removeChild(disObj);
						disObj=null;
					}
					break
			}
		}
		private function get sceneLayerVC():SceneLayerVC{
			return viewComponent as SceneLayerVC
		}
	}
}